package com.dubbodemo.consumer;

import com.dubbodemo.api.DemoService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class ConsumerThd implements Runnable {
  /**
   * 异步调用接口
   */
  public void run() {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
        new String[]{"consumer.xml"});
    context.start();

    DemoService someService = (DemoService) context.getBean("permissionService");
    List<String> result = someService.getPermissions(Long.valueOf(1).longValue());
    System.out.println("消费者获得的结果：" + result);
    try {
      Thread.sleep(1000 * 20);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    System.out.println(Thread.currentThread().getName());

  }

  public static void main(String[] args) {
    new Thread(new ConsumerThd()).start();
    /**
     * 输出结果：
     * Thread-0 Finished:nihao
     */
  }
}